{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "my = pd.read_csv('maoyanfilms_clean.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [],
   "source": [
    "# df新增一列,专门放上映年份的\n",
    "year_list = []\n",
    "for i in range(0,len(my)):\n",
    "    if type(my['film_first_time'][i])==str:\n",
    "        s = my['film_first_time'][i][0:4]\n",
    "        year_list.append(s)\n",
    "    else:\n",
    "        year_list.append(np.nan)\n",
    "my['films_year']=year_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [],
   "source": [
    " t_list = [] #存放电影类型的列表\n",
    "for i in range(0,len(my['films_type'])):\n",
    "   if type(my['films_type'][i])== str:\n",
    "    s_t = my['films_type'][i].split(',')\n",
    "    for j in s_t:\n",
    "        if j not in t_list:\n",
    "            t_list.append(j)  \n",
    "t_list.remove(' 青春 励志 爱情 ')\n",
    "t_list.remove('  ')\n",
    "t_list.remove(' 惊悚；恐怖；悬疑；爱情 ')\n",
    "t_list.remove(' 灵异/喜剧/悬疑 ')\n",
    "t_list.remove(' 爱情 恐怖 ')\n",
    "t_list.remove(' 爱情 / 喜剧 / 青春 ')\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [],
   "source": [
    "year_range_list = range(2000,2020) # 2000 ~ 2019年\n",
    "type_range_list = t_list[0:25] # 只统计类型当中的前25个\n",
    "year_count_list = [0]*len(year_range_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [],
   "source": [
    "for year in range(0,len(year_range_list)):\n",
    "    type_count_list = [0]*len(type_range_list)\n",
    "    f_t = my[my['films_year']==str(year_range_list[year])]['films_type']\n",
    "    for one in f_t:\n",
    "        if type(one) == str:\n",
    "            s_t = one.split(',') # list类型\n",
    "            for s in s_t: # 遍历s_t列表\n",
    "                for t in range(0,len(type_range_list)):\n",
    "                    if s == type_range_list[t]:\n",
    "                        type_count_list[t] += 1\n",
    "    year_count_list[year] = type_count_list # list存放在list中\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>2000</th>\n",
       "      <th>2002</th>\n",
       "      <th>2003</th>\n",
       "      <th>2004</th>\n",
       "      <th>2005</th>\n",
       "      <th>2006</th>\n",
       "      <th>2007</th>\n",
       "      <th>2008</th>\n",
       "      <th>2009</th>\n",
       "      <th>2010</th>\n",
       "      <th>2011</th>\n",
       "      <th>2012</th>\n",
       "      <th>2013</th>\n",
       "      <th>2014</th>\n",
       "      <th>2015</th>\n",
       "      <th>2016</th>\n",
       "      <th>2017</th>\n",
       "      <th>2018</th>\n",
       "      <th>2019</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>喜剧</th>\n",
       "      <td>34</td>\n",
       "      <td>30</td>\n",
       "      <td>31</td>\n",
       "      <td>35</td>\n",
       "      <td>28</td>\n",
       "      <td>29</td>\n",
       "      <td>33</td>\n",
       "      <td>30</td>\n",
       "      <td>30</td>\n",
       "      <td>48</td>\n",
       "      <td>119</td>\n",
       "      <td>146</td>\n",
       "      <td>159</td>\n",
       "      <td>161</td>\n",
       "      <td>154</td>\n",
       "      <td>254</td>\n",
       "      <td>188</td>\n",
       "      <td>115</td>\n",
       "      <td>103</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>爱情</th>\n",
       "      <td>33</td>\n",
       "      <td>37</td>\n",
       "      <td>30</td>\n",
       "      <td>28</td>\n",
       "      <td>29</td>\n",
       "      <td>25</td>\n",
       "      <td>35</td>\n",
       "      <td>43</td>\n",
       "      <td>36</td>\n",
       "      <td>60</td>\n",
       "      <td>183</td>\n",
       "      <td>257</td>\n",
       "      <td>269</td>\n",
       "      <td>240</td>\n",
       "      <td>179</td>\n",
       "      <td>222</td>\n",
       "      <td>220</td>\n",
       "      <td>153</td>\n",
       "      <td>138</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>剧情</th>\n",
       "      <td>80</td>\n",
       "      <td>83</td>\n",
       "      <td>71</td>\n",
       "      <td>66</td>\n",
       "      <td>88</td>\n",
       "      <td>86</td>\n",
       "      <td>88</td>\n",
       "      <td>114</td>\n",
       "      <td>148</td>\n",
       "      <td>156</td>\n",
       "      <td>546</td>\n",
       "      <td>655</td>\n",
       "      <td>639</td>\n",
       "      <td>566</td>\n",
       "      <td>465</td>\n",
       "      <td>457</td>\n",
       "      <td>586</td>\n",
       "      <td>487</td>\n",
       "      <td>477</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>音乐</th>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>6</td>\n",
       "      <td>3</td>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "      <td>21</td>\n",
       "      <td>33</td>\n",
       "      <td>42</td>\n",
       "      <td>28</td>\n",
       "      <td>25</td>\n",
       "      <td>16</td>\n",
       "      <td>15</td>\n",
       "      <td>20</td>\n",
       "      <td>17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>奇幻</th>\n",
       "      <td>8</td>\n",
       "      <td>11</td>\n",
       "      <td>4</td>\n",
       "      <td>9</td>\n",
       "      <td>6</td>\n",
       "      <td>6</td>\n",
       "      <td>5</td>\n",
       "      <td>4</td>\n",
       "      <td>12</td>\n",
       "      <td>8</td>\n",
       "      <td>29</td>\n",
       "      <td>49</td>\n",
       "      <td>39</td>\n",
       "      <td>41</td>\n",
       "      <td>39</td>\n",
       "      <td>63</td>\n",
       "      <td>62</td>\n",
       "      <td>41</td>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>运动</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>8</td>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "      <td>8</td>\n",
       "      <td>8</td>\n",
       "      <td>17</td>\n",
       "      <td>10</td>\n",
       "      <td>11</td>\n",
       "      <td>7</td>\n",
       "      <td>10</td>\n",
       "      <td>15</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>动作</th>\n",
       "      <td>50</td>\n",
       "      <td>25</td>\n",
       "      <td>28</td>\n",
       "      <td>38</td>\n",
       "      <td>30</td>\n",
       "      <td>25</td>\n",
       "      <td>19</td>\n",
       "      <td>26</td>\n",
       "      <td>23</td>\n",
       "      <td>30</td>\n",
       "      <td>49</td>\n",
       "      <td>55</td>\n",
       "      <td>65</td>\n",
       "      <td>65</td>\n",
       "      <td>80</td>\n",
       "      <td>115</td>\n",
       "      <td>125</td>\n",
       "      <td>102</td>\n",
       "      <td>74</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>战争</th>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>5</td>\n",
       "      <td>3</td>\n",
       "      <td>8</td>\n",
       "      <td>5</td>\n",
       "      <td>42</td>\n",
       "      <td>30</td>\n",
       "      <td>19</td>\n",
       "      <td>23</td>\n",
       "      <td>17</td>\n",
       "      <td>18</td>\n",
       "      <td>21</td>\n",
       "      <td>16</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>历史</th>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>6</td>\n",
       "      <td>11</td>\n",
       "      <td>13</td>\n",
       "      <td>48</td>\n",
       "      <td>35</td>\n",
       "      <td>31</td>\n",
       "      <td>25</td>\n",
       "      <td>34</td>\n",
       "      <td>17</td>\n",
       "      <td>22</td>\n",
       "      <td>18</td>\n",
       "      <td>25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>传记</th>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>7</td>\n",
       "      <td>7</td>\n",
       "      <td>14</td>\n",
       "      <td>39</td>\n",
       "      <td>32</td>\n",
       "      <td>33</td>\n",
       "      <td>22</td>\n",
       "      <td>36</td>\n",
       "      <td>6</td>\n",
       "      <td>16</td>\n",
       "      <td>18</td>\n",
       "      <td>17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>古装</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>6</td>\n",
       "      <td>3</td>\n",
       "      <td>6</td>\n",
       "      <td>12</td>\n",
       "      <td>20</td>\n",
       "      <td>24</td>\n",
       "      <td>16</td>\n",
       "      <td>12</td>\n",
       "      <td>21</td>\n",
       "      <td>22</td>\n",
       "      <td>30</td>\n",
       "      <td>34</td>\n",
       "      <td>28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>武侠</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>13</td>\n",
       "      <td>8</td>\n",
       "      <td>6</td>\n",
       "      <td>4</td>\n",
       "      <td>16</td>\n",
       "      <td>13</td>\n",
       "      <td>28</td>\n",
       "      <td>29</td>\n",
       "      <td>15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>动画</th>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>9</td>\n",
       "      <td>14</td>\n",
       "      <td>9</td>\n",
       "      <td>5</td>\n",
       "      <td>9</td>\n",
       "      <td>17</td>\n",
       "      <td>24</td>\n",
       "      <td>30</td>\n",
       "      <td>116</td>\n",
       "      <td>160</td>\n",
       "      <td>174</td>\n",
       "      <td>176</td>\n",
       "      <td>200</td>\n",
       "      <td>110</td>\n",
       "      <td>62</td>\n",
       "      <td>63</td>\n",
       "      <td>72</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>悬疑</th>\n",
       "      <td>9</td>\n",
       "      <td>8</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "      <td>2</td>\n",
       "      <td>7</td>\n",
       "      <td>6</td>\n",
       "      <td>8</td>\n",
       "      <td>14</td>\n",
       "      <td>7</td>\n",
       "      <td>42</td>\n",
       "      <td>73</td>\n",
       "      <td>74</td>\n",
       "      <td>78</td>\n",
       "      <td>88</td>\n",
       "      <td>145</td>\n",
       "      <td>114</td>\n",
       "      <td>107</td>\n",
       "      <td>70</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>家庭</th>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>7</td>\n",
       "      <td>6</td>\n",
       "      <td>10</td>\n",
       "      <td>9</td>\n",
       "      <td>10</td>\n",
       "      <td>18</td>\n",
       "      <td>27</td>\n",
       "      <td>23</td>\n",
       "      <td>66</td>\n",
       "      <td>118</td>\n",
       "      <td>109</td>\n",
       "      <td>107</td>\n",
       "      <td>99</td>\n",
       "      <td>66</td>\n",
       "      <td>75</td>\n",
       "      <td>73</td>\n",
       "      <td>71</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>冒险</th>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>5</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>10</td>\n",
       "      <td>6</td>\n",
       "      <td>16</td>\n",
       "      <td>28</td>\n",
       "      <td>23</td>\n",
       "      <td>39</td>\n",
       "      <td>35</td>\n",
       "      <td>35</td>\n",
       "      <td>35</td>\n",
       "      <td>32</td>\n",
       "      <td>33</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>惊悚</th>\n",
       "      <td>21</td>\n",
       "      <td>19</td>\n",
       "      <td>17</td>\n",
       "      <td>14</td>\n",
       "      <td>7</td>\n",
       "      <td>13</td>\n",
       "      <td>13</td>\n",
       "      <td>18</td>\n",
       "      <td>17</td>\n",
       "      <td>18</td>\n",
       "      <td>34</td>\n",
       "      <td>45</td>\n",
       "      <td>32</td>\n",
       "      <td>35</td>\n",
       "      <td>67</td>\n",
       "      <td>111</td>\n",
       "      <td>66</td>\n",
       "      <td>50</td>\n",
       "      <td>20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>犯罪</th>\n",
       "      <td>46</td>\n",
       "      <td>18</td>\n",
       "      <td>27</td>\n",
       "      <td>15</td>\n",
       "      <td>13</td>\n",
       "      <td>14</td>\n",
       "      <td>12</td>\n",
       "      <td>11</td>\n",
       "      <td>16</td>\n",
       "      <td>11</td>\n",
       "      <td>27</td>\n",
       "      <td>47</td>\n",
       "      <td>38</td>\n",
       "      <td>44</td>\n",
       "      <td>50</td>\n",
       "      <td>86</td>\n",
       "      <td>83</td>\n",
       "      <td>54</td>\n",
       "      <td>49</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>纪录片</th>\n",
       "      <td>19</td>\n",
       "      <td>18</td>\n",
       "      <td>35</td>\n",
       "      <td>26</td>\n",
       "      <td>28</td>\n",
       "      <td>25</td>\n",
       "      <td>42</td>\n",
       "      <td>34</td>\n",
       "      <td>59</td>\n",
       "      <td>63</td>\n",
       "      <td>222</td>\n",
       "      <td>242</td>\n",
       "      <td>249</td>\n",
       "      <td>229</td>\n",
       "      <td>282</td>\n",
       "      <td>165</td>\n",
       "      <td>194</td>\n",
       "      <td>206</td>\n",
       "      <td>235</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>歌舞</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>8</td>\n",
       "      <td>8</td>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "      <td>8</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>7</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>短片</th>\n",
       "      <td>8</td>\n",
       "      <td>9</td>\n",
       "      <td>16</td>\n",
       "      <td>22</td>\n",
       "      <td>20</td>\n",
       "      <td>13</td>\n",
       "      <td>27</td>\n",
       "      <td>44</td>\n",
       "      <td>65</td>\n",
       "      <td>67</td>\n",
       "      <td>305</td>\n",
       "      <td>500</td>\n",
       "      <td>637</td>\n",
       "      <td>477</td>\n",
       "      <td>424</td>\n",
       "      <td>244</td>\n",
       "      <td>198</td>\n",
       "      <td>222</td>\n",
       "      <td>272</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>灾难</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>5</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>西部</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>科幻</th>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>6</td>\n",
       "      <td>8</td>\n",
       "      <td>19</td>\n",
       "      <td>23</td>\n",
       "      <td>24</td>\n",
       "      <td>29</td>\n",
       "      <td>41</td>\n",
       "      <td>28</td>\n",
       "      <td>33</td>\n",
       "      <td>24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>恐怖</th>\n",
       "      <td>22</td>\n",
       "      <td>30</td>\n",
       "      <td>16</td>\n",
       "      <td>15</td>\n",
       "      <td>12</td>\n",
       "      <td>5</td>\n",
       "      <td>10</td>\n",
       "      <td>11</td>\n",
       "      <td>12</td>\n",
       "      <td>8</td>\n",
       "      <td>11</td>\n",
       "      <td>18</td>\n",
       "      <td>18</td>\n",
       "      <td>20</td>\n",
       "      <td>28</td>\n",
       "      <td>59</td>\n",
       "      <td>38</td>\n",
       "      <td>24</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       2000  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  \\\n",
       " 喜剧      34    30    31    35    28    29    33    30    30    48   119   146   \n",
       " 爱情      33    37    30    28    29    25    35    43    36    60   183   257   \n",
       " 剧情      80    83    71    66    88    86    88   114   148   156   546   655   \n",
       " 音乐       4     4     4     0     3     1     6     3     5     6    21    33   \n",
       " 奇幻       8    11     4     9     6     6     5     4    12     8    29    49   \n",
       " 运动       0     0     0     0     2     2     1     8     4     2     8     8   \n",
       " 动作      50    25    28    38    30    25    19    26    23    30    49    55   \n",
       " 战争       2     3     3     2     3     3     5     3     8     5    42    30   \n",
       " 历史       4     2     1     3     3     3     4     6    11    13    48    35   \n",
       " 传记       0     4     3     3     2     3     4     7     7    14    39    32   \n",
       " 古装       2     2     4     2     4     1     6     3     6    12    20    24   \n",
       " 武侠       2     2     1     1     1     1     5     2     4     4    13     8   \n",
       " 动画       3     3     9    14     9     5     9    17    24    30   116   160   \n",
       " 悬疑       9     8     6     7     2     7     6     8    14     7    42    73   \n",
       " 家庭       5     2     7     6    10     9    10    18    27    23    66   118   \n",
       " 冒险       3     3     5     3     2     1     1     2    10     6    16    28   \n",
       " 惊悚      21    19    17    14     7    13    13    18    17    18    34    45   \n",
       " 犯罪      46    18    27    15    13    14    12    11    16    11    27    47   \n",
       " 纪录片     19    18    35    26    28    25    42    34    59    63   222   242   \n",
       " 歌舞       1     1     2     1     2     1     2     0     3     2     8     8   \n",
       " 短片       8     9    16    22    20    13    27    44    65    67   305   500   \n",
       " 灾难       1     0     1     0     0     0     0     1     0     1     3     5   \n",
       " 西部       1     0     0     1     0     1     1     0     1     3     3     3   \n",
       " 科幻       1     2     1     4     3     1     4     2     1     6     8    19   \n",
       " 恐怖      22    30    16    15    12     5    10    11    12     8    11    18   \n",
       "\n",
       "       2013  2014  2015  2016  2017  2018  2019  \n",
       " 喜剧     159   161   154   254   188   115   103  \n",
       " 爱情     269   240   179   222   220   153   138  \n",
       " 剧情     639   566   465   457   586   487   477  \n",
       " 音乐      42    28    25    16    15    20    17  \n",
       " 奇幻      39    41    39    63    62    41    40  \n",
       " 运动      17    10    11     7    10    15    14  \n",
       " 动作      65    65    80   115   125   102    74  \n",
       " 战争      19    23    17    18    21    16    23  \n",
       " 历史      31    25    34    17    22    18    25  \n",
       " 传记      33    22    36     6    16    18    17  \n",
       " 古装      16    12    21    22    30    34    28  \n",
       " 武侠       6     4    16    13    28    29    15  \n",
       " 动画     174   176   200   110    62    63    72  \n",
       " 悬疑      74    78    88   145   114   107    70  \n",
       " 家庭     109   107    99    66    75    73    71  \n",
       " 冒险      23    39    35    35    35    32    33  \n",
       " 惊悚      32    35    67   111    66    50    20  \n",
       " 犯罪      38    44    50    86    83    54    49  \n",
       " 纪录片    249   229   282   165   194   206   235  \n",
       " 歌舞       9     9     8     5     5     7    10  \n",
       " 短片     637   477   424   244   198   222   272  \n",
       " 灾难       4     4     2     2     3     4     2  \n",
       " 西部       1     0     2     3     1     2     0  \n",
       " 科幻      23    24    29    41    28    33    24  \n",
       " 恐怖      18    20    28    59    38    24     9  "
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 构建数据框 DataFrmae\n",
    "fims_type_year_df = pd.DataFrame(\n",
    "    year_count_list[0],\n",
    "    columns= ['2000'],\n",
    "    index=type_range_list,\n",
    ")\n",
    "for i in range(2,20):\n",
    "    s = str(year_range_list[i])\n",
    "    fims_type_year_df[s] = year_count_list[i]\n",
    "fims_type_year_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "for i in type_range_list:\n",
    "    s = '.add_yaxis(\"'+i+'\",fims_type_year_df.loc[\"'+i+'\"])'\n",
    "#     print(s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pyecharts.options as opts\n",
    "from pyecharts.charts import Line\n",
    "c = (\n",
    "    Line()\n",
    "    .add_xaxis(list(fims_type_year_df.columns))\n",
    "    .add_yaxis(\" 喜剧 \",fims_type_year_df.loc[\" 喜剧 \"])\n",
    "    .add_yaxis(\" 爱情 \",fims_type_year_df.loc[\" 爱情 \"])\n",
    "    .add_yaxis(\" 剧情 \",fims_type_year_df.loc[\" 剧情 \"])\n",
    "    .add_yaxis(\" 音乐 \",fims_type_year_df.loc[\" 音乐 \"])\n",
    "    .add_yaxis(\" 奇幻 \",fims_type_year_df.loc[\" 奇幻 \"])\n",
    "    .add_yaxis(\" 运动 \",fims_type_year_df.loc[\" 运动 \"])\n",
    "    .add_yaxis(\" 动作 \",fims_type_year_df.loc[\" 动作 \"])\n",
    "    .add_yaxis(\" 战争 \",fims_type_year_df.loc[\" 战争 \"])\n",
    "    .add_yaxis(\" 历史 \",fims_type_year_df.loc[\" 历史 \"])\n",
    "    .add_yaxis(\" 传记 \",fims_type_year_df.loc[\" 传记 \"])\n",
    "    .add_yaxis(\" 古装 \",fims_type_year_df.loc[\" 古装 \"])\n",
    "    .add_yaxis(\" 武侠 \",fims_type_year_df.loc[\" 武侠 \"])\n",
    "    .add_yaxis(\" 动画 \",fims_type_year_df.loc[\" 动画 \"])\n",
    "    .add_yaxis(\" 悬疑 \",fims_type_year_df.loc[\" 悬疑 \"])\n",
    "    .add_yaxis(\" 家庭 \",fims_type_year_df.loc[\" 家庭 \"])\n",
    "    .add_yaxis(\" 冒险 \",fims_type_year_df.loc[\" 冒险 \"])\n",
    "    .add_yaxis(\" 惊悚 \",fims_type_year_df.loc[\" 惊悚 \"])\n",
    "    .add_yaxis(\" 犯罪 \",fims_type_year_df.loc[\" 犯罪 \"])\n",
    "    .add_yaxis(\" 纪录片 \",fims_type_year_df.loc[\" 纪录片 \"])\n",
    "    .add_yaxis(\" 歌舞 \",fims_type_year_df.loc[\" 歌舞 \"])\n",
    "    .add_yaxis(\" 短片 \",fims_type_year_df.loc[\" 短片 \"])\n",
    "    .add_yaxis(\" 灾难 \",fims_type_year_df.loc[\" 灾难 \"])\n",
    "    .add_yaxis(\" 西部 \",fims_type_year_df.loc[\" 西部 \"])\n",
    "    .add_yaxis(\" 科幻 \",fims_type_year_df.loc[\" 科幻 \"])\n",
    "    .add_yaxis(\" 恐怖 \",fims_type_year_df.loc[\" 恐怖 \"])\n",
    "    .add_yaxis(\" 青春，爱情 \",fims_type_year_df.loc[\" 青春，爱情 \"])\n",
    "    .render(\"不同类型电影随时间的变化.html\")\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
